#include <bits/stdc++.h>

#include <atcoder/all>
#define LL long long
using namespace std;
using namespace atcoder;

vector<vector<int>> g;
vector<bool> vis;

void DFS(int now) {
  vis[now] = true;

  for (int next : g[now]) {
    if (!vis[next]) {
      DFS(next);
    }
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int N, M, Q;

  cin >> N >> M;
  g.resize(N + 1);
  vis.resize(N + 1, false);
  for (int i = 0; i < M; i++) {
    int X, Y;

    cin >> X >> Y;
    g[Y].emplace_back(X);
  }
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int t, v;

    cin >> t >> v;
    if (t == 1) {
      if (!vis[v]) {
        DFS(v);
      }
    } else {
      cout << (vis[v] ? "Yes\n" : "No\n");
    }
  }
  return 0;
}
